package net.ufrog.common.data;

import net.ufrog.common.Logger;
import org.junit.Assert;
import org.junit.Test;

/**
 * @author ultrafrog, ufrog.net@gmail.com
 * @version 0.1, 2017-01-29
 * @since 0.1
 */
public class QueryScriptTester {

    @Test
    public void testParseQl() {
        String ql = "select u.vc_name, u.nb_age, u.dc_gender from @user u where u.nb_age > 14 order by u.vc_name asc";
        QueryScript qs = new QueryScript(ql);

        Logger.info("script without order: %s", qs.getScriptWithoutOrder());
        Assert.assertEquals("select u.vc_name, u.nb_age, u.dc_gender from @user u where u.nb_age > 14", qs.getScriptWithoutOrder());

        Logger.info("full script: %s", qs.getScript());
        Assert.assertEquals(ql, qs.getScript());

        Logger.info("count script: %s", qs.getCountScript());
        Assert.assertEquals("select count(*) from @user u where u.nb_age > 14", qs.getCountScript());
    }
}
